<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="LINE" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="MULTILINE" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="DROPDOWN_LIST" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="RADIO_BUTTONS" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="CHECK_BOXES" />
<atleap:constants className="com.blandware.atleap.model.questionnaire.Question" scope="page" var="MULTILIST" />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />

<atleap:content identifier="information" ignore="true" />
<table cellpadding="0" cellspacing="0" border="0" class="tableView">
    <tr>
        <th align="left" width="50%"><atleap:message key="questionnaire.question.form.type" /></th>
        <td><atleap:message key="questionnaire.question.form.type.${question.type}" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="questionnaire.question.form.required" /></th>
        <td>
            <c:choose>
                <c:when test="${question.required}">
                    <atleap:message key="core.commons.boolean.true" />
                </c:when>
                <c:otherwise>
                    <atleap:message key="core.commons.boolean.false" />
                </c:otherwise>
            </c:choose>
        </td>
    </tr>
    <c:if test="${question.textual}">
        <tr>
            <th align="left" width="50%"><atleap:message key="questionnaire.question.form.validationRegex" /></th>
            <td><c:out value="${question.validationRegex}" /></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <atleap:message key="questionnaire.question.form.title" />
            </td>
        </tr>
    </c:if>
	<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
        <tr>
            <th>
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:
				</div>
            </th>
            <td>
                <atleap:iframe src="${ctxPath}/blank.html">
                    <atleap:fieldValue valueMap="${requestScope.question.title}" language="${contentLocale.identifier}" complexSearch="false" filter="false" />
                </atleap:iframe>
            </td>
    	</tr>
	</atleap:iterator>
</table>
<atleap:form action="questionnaire/question/callUpdate" method="POST" validateOnSubmit="false">
    <html:hidden property="id" value="${requestScope.question.id}" />
    <c:if test="${!requestScope.question.questionnaire.fixed}">
        <atleap:isUserInRole roles="questionnaire-question-update">
            <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.callUpdate" /></atleap:submit>
        </atleap:isUserInRole>
    </c:if>
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.showList" /></atleap:cancel>
</atleap:form>

<c:if test="${requestScope.question.multiOption}">
    <atleap:isUserInRole roles="questionnaire-answerOption-list">
        <%-- List of questions for this questionnaire --%>
        <h3>
            <atleap:message key="questionnaire.answerOption.list" />
        </h3>
        <tiles:get name="listAnswerOptions" />
    </atleap:isUserInRole>
</c:if>